<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="edu.jhu.secondhome.database.beans.Room"%>
<%@page import="edu.jhu.secondhome.database.beans.Hotel"%>
<!DOCTYPE html>
<html>
<head>
<title>Second Home Inc. :: Hotel Info</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="search_includes.jsp"%>
</head>
<body>
	<div id="page-wrap" align="center">
		<%@ include file="../navigation.jsp"%>
		<p style="color: white">
			The following rooms are available for your requested <b><%=request.getAttribute( "numDays" )%>
				night</b> stay.
		</p>
		<%
		  Hotel hotel = (Hotel) request.getAttribute( "hotel" );

		  String addr1 = "";
		  String addr2 = "";
		  String addr3 = "";
		  String city = "";
		  String state = "";
		  String zip = "";
		  if ( hotel != null )
		  {
		    addr1 = hotel.getAddressSubField( "addr1" );
		    addr2 = hotel.getAddressSubField( "addr2" );
		    addr3 = hotel.getAddressSubField( "addr3" );
		    city = hotel.getAddressSubField( "city" );
		    state = hotel.getAddressSubField( "state" );
		    zip = hotel.getAddressSubField( "zip" );
		  }
		%>

		<form action="controller" method="post">
			<table id="rooms">
				<thead>
					<tr>
						<th colspan="4" style="font-size: 1.25em; padding: 10px;">${hotel.hotelName} - <%= request.getAttribute( "check-in" ) + " to " + request.getAttribute( "check-out" ) %></th>
					</tr>
					<tr>
						<th>Room Number</th>
						<th>Maximum Occupancy</th>
						<th>Nightly Rate</th>
						<th>Total Cost</th>
					</tr>
				</thead>

				<tbody>
					<%
					  int i = 0;
					%>
					<c:forEach items="${rooms}" var="room">
						<%
						  Room room = (Room) pageContext.getAttribute( "room" );
						%>
						<tr id="row<%= i %>">
							<td><input type="radio" name="roomNum" value="${room.roomNumber}"/>${room.roomNumber}</td>
							<td>${room.occupancy} people</td>
							<td>$${room.costPerNight}.00</td>
							<td>$<%=(Integer) request.getAttribute( "numDays" ) * room.getCostPerNight()%>.00</td>
						</tr>
						<%
						  i++;
						%>
					</c:forEach>
				</tbody>
			</table>
			<br />
			<input type="hidden" name="source" value="hotelInfo" />
			<input type="hidden" name="from" value="/availableRooms" />
			<input type="hidden" name="hotelName" value="${hotel.hotelName}"/>
		  <input type="hidden" name="check-in" value="<%= request.getAttribute( "check-in" ) %>"/>
		  <input type="hidden" name="numDays" value="<%= request.getAttribute( "numDays" ) %>"/>
		  <input type="hidden" name="numPeople" value="<%= request.getAttribute( "numPeople" ) %>"/>
			<input type="submit" name="checkout" value="Checkout" />
		</form>
	</div>

</body>
</html>